function ajaxSubmit(frm,url,fn) {
    var dataPara = getFormJson(frm);
    $.ajax({
        url: url,
        type: frm.method,
        data: dataPara,
        dataType: 'json',
        success: function (data) {
            if (typeof data == 'string') {
                try {
                    data = eval('(' + data + ')');
                } catch (e) {

                }
            }
            if (typeof fn == 'function') {
                fn(data);
            }

        },
        error: function () {
            layer.msg('网络连接错误');
        }
    });
}

//将form中的值转换为键值对。
function getFormJson(frm) {
    var o = {};
    var a = $(frm).serializeArray();
    $.each(a, function () {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });

    return o;
}